package com.sh.caryr.erp.service.impl.basis;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.sh.caryr.erp.entity.basis.CompCfg;
import com.sh.caryr.erp.entity.definition.CommonFieldDef;
import com.sh.caryr.erp.mapper.basis.CompCfgMapper;
import com.sh.caryr.erp.service.ICompCfgService;
import com.sh.caryr.erp.util.MyBatisUtil;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CompCfgServiceImpl extends ServiceImpl<CompCfgMapper, CompCfg> implements ICompCfgService {

    @Override
    public List<CompCfg> loadCompCfgByCoco(String coco) {
        return selectList(MyBatisUtil.getIsActiveWrapper().eq(CommonFieldDef.COCO, coco));
    }

    @Override
    public CompCfg loadCompCfgByCocoAndPlatform(String platform, String coco) {
        List<CompCfg> compCfgs = selectList(MyBatisUtil.getIsActiveWrapper().eq(CommonFieldDef.EXT_PLATFORM, platform).eq(CommonFieldDef.COCO, coco));
        return CollectionUtils.isEmpty(compCfgs) ? null : compCfgs.get(0);
    }
}
